<template>
  <div>
    <!-- <template v-if="generatedNum == 1"> -->
    <div class="part-title divider-inside">Part VI Recording Of Operations</div>
    <div class="table-1 divider-inside">
      <div class="table-header divider-inside">Task Codes</div>
      <div class="table-body">
        <div
          class="row divider-inside"
          v-for="(item, index) in data_task_code"
          :key="index"
        >
          <div
            v-for="(value, key, index) of item"
            :key="index"
            :class="index == 0 ? 'label' : 'value'"
          >
            {{ index == 0 ? item.title : item.content }}
          </div>
        </div>
      </div>
    </div>
    <!-- </template> -->
    <table style="width: 100%; margin-top: 0">
      <!-- v-if="generatedNum == 1" -->
      <thead>
        <tr class="divider-inside">
          <td rowspan="2">Date</td>
          <td colspan="3">AIRCRAFT</td>
          <td colspan="8">ACTION</td>
          <td colspan="3" class="custom">
            <div style="padding: 0">
              <span>FUNCTION</span>
              <span>SIGNATURE</span>
            </div>
          </td>
        </tr>
        <tr class="divider-inside">
          <td>Type</td>
          <td>AC Reg</td>
          <td>ATA Chapter</td>
          <td>Subject</td>
          <td>SGH</td>
          <td>R/I</td>
          <td>TS</td>
          <td>FOT</td>
          <td>ISP</td>
          <td>MP</td>
          <td>
            Time <br />
            spent
          </td>
          <td>Execution Person</td>
          <td>Supervisor</td>
          <td>CRS</td>
        </tr>
      </thead>
      <tbody>
        <tr class="divider-inside" v-for="(item, index) in data" :key="item.id">
          <td>
            <div class="nowrap">
              {{ item.date }}
            </div>
          </td>
          <td>
            <div class="nowrap nopadding">
              {{ item.type_new }}
            </div>
          </td>
          <td>
            <div class="nowrap">
              {{ item.ac }}
            </div>
          </td>
          <td>
            <div class="nowrap w-cell">
              {{ item.ata }}
            </div>
          </td>
          <td>
            <div class="align-left">
              {{ item.subject }}
            </div>
          </td>
          <td>
            <div class="w-cell">
              <IconCheck v-if="item.sgh == '1'"></IconCheck>
              <span v-else>-</span>
            </div>
          </td>
          <td>
            <div class="w-cell">
              <IconCheck v-if="item.ri == '1'"></IconCheck>
              <span v-else>-</span>
            </div>
          </td>
          <td>
            <div class="w-cell">
              <IconCheck v-if="item.ts == '1'"></IconCheck>
              <span v-else>-</span>
            </div>
          </td>
          <td>
            <div class="w-cell">
              <IconCheck v-if="item.fot == '1'"></IconCheck>
              <span v-else>-</span>
            </div>
          </td>
          <td>
            <div class="w-cell">
              <IconCheck v-if="item.isp == '1'"></IconCheck>
              <span v-else>-</span>
            </div>
          </td>
          <td>
            <div class="w-cell">
              <IconCheck v-if="item.mp == '1'"></IconCheck>
              <span v-else>-</span>
            </div>
          </td>
          <td>
            <div class="w-cell">
              {{ item.timespent }}
            </div>
          </td>
          <td>
            <div class="w-cell">
              <IconCheck v-if="item.execution_person == '1'"></IconCheck>
              <span v-else>-</span>
            </div>
          </td>
          <td>
            <div class="w-cell">
              <IconCheck v-if="item.supervisor == '1'"></IconCheck>
              <span v-else>-</span>
            </div>
          </td>
          <td>
            <div class="w-cell">
              <IconCheck v-if="item.crs == '1'"></IconCheck>
              <span v-else>-</span>
            </div>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script setup lang="ts">
import { computed, inject } from "vue";

const journalData: any = inject("journalData");

const data = computed(() => {
  return journalData.value[7].data
});

// const data =  journalData.value[7].data

const data_task_code = journalData.value[6].data;
</script>
<style scoped lang="less">
@import url("../less/index.less");

table {
  margin-top: 100px;
  text-align: center;
  .border();
  font-size: 10px;
  line-height: 1.6;
  td {
    div {
      // height:50px;
      padding: 10px 10px;
      // height: 62.5px;
      display: flex;
      justify-content: center;
      align-items: center;
      &.align-left {
        text-align: left !important;
        justify-content: flex-start;
        // text-overflow: ellipsis;
        // overflow: hidden;
        // display: -webkit-box;
        // -webkit-line-clamp: 3;
        // -webkit-box-orient: vertical;
      }
      &.nopadding {
        padding: 0;
      }
      &.nowrap {
        white-space: nowrap;
      }
      &.w-cell {
        min-width: 50px;
      }
    }
  }
  thead {
    td {
      .border-bottom();
      &:not(:last-child) {
        .border-right();
      }
      &.custom {
        padding: 0;
        div {
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;
          span {
            padding: 5px;
            flex: 1;
            align-self: stretch;
            &:first-child {
              .border-bottom();
            }
          }
        }
      }
    }
  }
  tbody {
    td {
      word-break: break-all;
      .border-bottom();
      &:not(:last-child) {
        .border-right();
      }
      &.subject {
        text-align: left;
      }
      &.set-width {
        width: 70px;
      }
    }
    tr:last-child {
      td {
        border-bottom: none;
      }
    }
  }
}

.content {
  min-height: 500px;
  padding: 30px 50px;
  box-sizing: border-box;
  .border();
}

.table-1,
.table-2 {
  font-size: 20px;
}

.table-1 {
  width: 800px;
  margin: 0 auto;
  margin-bottom: 100px;
  .border();
  border-bottom: none;
  .table-header {
    background-color: #06214c;
    color: #fff;
    font-weight: 600;
    height: 40px;
    text-align: center;
    line-height: 40px;
    .border-bottom();
  }
  .table-body {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    font-size: 14px;
    .row {
      display: flex;
      .border-bottom();
      &:nth-child(n + 3) {
        background-color: #f2f2f2;
      }
      & > div {
        height: 30px;
        line-height: 30px;
        text-align: center;
      }
      .label {
        font-weight: 600;
        width: 60px;
        box-sizing: border-box;
      }
      .value {
        flex: 1;
      }
    }
  }
}

.table-2 {
  font-size: 15px;
  margin-top: 50px;
  .row-flex {
    display: flex;
    &.grow {
      & > div {
        flex: 1;
      }
    }
  }
  .column-flex {
    display: flex;
    flex-direction: column;
    & > div {
      flex: 1;
    }
  }
  .flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .table-header {
    text-align: center;
    .border();
    .col-center,
    .col-end,
    .col-start {
      & > div:first-child,
      & > div:last-child > div {
        display: flex;
        justify-content: center;
        align-items: center;
        flex: 1;
        box-sizing: border-box;
      }
      & > div:first-child {
        .border-bottom();
      }
      & > div:last-child {
        & > div {
          .border-right();
          &:last-child {
            border-right: none;
          }
        }
      }
    }
    .col-end {
      display: flex;
      flex-direction: column;
      & > div {
        flex: 1;
      }
      & > div:first-child {
        .border-bottom();
        flex-direction: column;
        & > div {
          flex: 1;
          align-self: stretch;
          display: flex;
          align-items: center;
          justify-content: center;
          &:first-child {
            .border-bottom();
          }
        }
      }
    }
    .col-center {
      & > div:last-child {
        & > div {
          flex: 0 1 auto;
          &:nth-child(n + 2) {
            width: 70px;
          }
          &:first-child {
            flex: 1;
          }
        }
      }
    }
  }
  .table-body {
    .border();
    border-bottom: none;
    border-top: none;
    .row-item {
      .row-flex {
        .border-bottom();
        & > div {
          padding: 10px;
          flex: 1;
          display: flex;
          align-items: center;
          justify-content: center;
          .border-right();
          &:last-child {
            border-right: none;
          }
          &.subject {
            justify-content: flex-start;
          }
        }
        &.col-center {
          & > div {
            flex: 0 1 auto;
            &:nth-child(n + 2) {
              width: 70px;
            }
            &:first-child {
              flex: 1;
            }
          }
        }
      }
    }
    .date {
      .border-bottom();
    }
  }
  .date {
    .border-right();
    width: 100px;
  }
  .col-start {
    width: 300px;
    .border-right();
  }
  .col-end {
    width: 350px;
  }
  .col-center {
    .border-right();
  }
}

// 设置line-height
.table-2 {
  .row-item {
    min-height: 50px;
  }
  .table-header {
    .date {
      min-height: 120px;
    }
  }
}
</style>
